// AssessmentDetailController.java
package com.projects.modular.realty.controller;

import com.projects.modular.realty.entity.AssessmentDetail;
import com.projects.modular.realty.model.params.AssessmentDetailParam;
import com.projects.modular.realty.service.AssessmentDetailService;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 评估详情控制器
 *
 * @author 曾大顺
 * @since 2025-02-11
 */
@RestController
@RequestMapping("/api/assessment-detail")
@Api(tags = "评估详情管理")
public class AssessmentDetailController {

    @Autowired
    private AssessmentDetailService assessmentDetailService;

    /**
     * 新增评估详情
     *
     * @author 曾大顺
     * @since 2025-02-11
     */
    @ApiOperation("新增评估详情")
    @PostMapping("/add")
    public ResponseData add(@RequestBody AssessmentDetailParam assessmentDetailParam) {
        this.assessmentDetailService.add(assessmentDetailParam);
        return ResponseData.success("添加成功");
    }

    /**
     * 编辑评估详情
     *
     * @author 曾大顺
     * @since 2025-02-11
     */
    @ApiOperation("编辑评估详情")
    @PostMapping("/edit")
    public ResponseData edit(@RequestBody AssessmentDetailParam assessmentDetailParam) {
        this.assessmentDetailService.update(assessmentDetailParam);
        return ResponseData.success("修改成功");
    }

    /**
     * 删除评估详情
     *
     * @author 曾大顺
     * @since 2025-02-11
     */
    @ApiOperation("删除评估详情")
    @GetMapping("/delete")
    public ResponseData delete(@RequestParam String assessmentDetailId) {
        this.assessmentDetailService.deleteById(assessmentDetailId);
        return ResponseData.success("删除成功");
    }

    /**
     * 查看详情
     *
     * @author 曾大顺
     * @since 2025-02-11
     */
    @ApiOperation("查看评估详情")
    @GetMapping("/detail")
    public ResponseData detail(@RequestParam String assessmentDetailId) {
        AssessmentDetail detail = this.assessmentDetailService.getById(assessmentDetailId);
        return ResponseData.success(detail);
    }

    /**
     * 根据评估ID查询所有评估详情
     *
     * @author 曾大顺
     * @since 2025-02-11
     */
    @ApiOperation("根据诊断ID查询所有评估详情")
    @GetMapping("/list")
    public ResponseData list(@RequestParam String diagnosisId) {
        List<AssessmentDetail> assessmentDetailList = this.assessmentDetailService.getByDiagnosisId(diagnosisId);
        return ResponseData.success(assessmentDetailList);
    }
}
